
let layer = layui.layer;
let form = layui.form;

form.verify({
    name: [/^[a-z][a-zA-Z0-9]{2,9}$/, '需要以字母开头，字母和数字 3到10位'],
    same: function (value, item) {
        let k = $('input[type="password"]').val();

        if (value != k) {
            return "两次密码输入不相同"
        }
    },
    pass: [
        /^[\S]{6,12}$/
        , '密码必须6到12位，且不能出现空格'
    ]

})
$('form').on('submit', function (e) {
    e.preventDefault();
    $.ajax({
        url: 'admin/users',
        type: 'post',
        data: $(this).serialize(),
        success: function (res) {
            if (res.status == 0) {
                location.href = './user.html';
            }
            layer.msg(res, message);
        }
    })
})

$('form').on('reset', function (e) {
    e.preventDefault();
    $(this).reset();
})
